package com.ms.pda.components

import android.content.Context
import android.widget.TextView
import com.lxj.xpopup.core.CenterPopupView
import com.ms.pda.R
import com.ms.pda.interf.OnSelectCallback

class SelectModeDialog(context: Context) : CenterPopupView(context) {

    private var callback: OnSelectCallback? = null
    private var title: String = ""
    private var left: String = ""
    private var right: String = ""

    constructor(
        context: Context,
        title: String,
        left: String,
        right: String,
        callback: OnSelectCallback?
    ) : this(context) {
        this.title = title
        this.left = left
        this.right = right
        this.callback = callback
    }

    override fun getImplLayoutId(): Int {
        return R.layout.dialog_select_mode
    }

    override fun onCreate() {
        super.onCreate()
        val titleView: TextView = findViewById(R.id.dialog_title)
        val leftView: TextView = findViewById(R.id.dialog_left)
        val rightView: TextView = findViewById(R.id.dialog_right)
        titleView.text = title
        leftView.text = left
        rightView.text = right
        leftView.setOnClickListener {
            dismiss()
            callback?.onLeft()
        }
        rightView.setOnClickListener {
            dismiss()
            callback?.onRight()
        }
    }
}